using UnityEngine;
using System.Collections;

public static class GameControl
{
    #region Attributes

    public static bool isInputEnabled = true;

    #endregion

    #region Static Methods

    public static void LoadScene(string name)
    {
        GameControl.isInputEnabled = false;
        Application.LoadLevel(name);
    }

    public static PlayerControl FindPlayer()
    {
        PlayerControl player = null;

        GameObject playerGameObject = GameObject.FindGameObjectWithTag(TagConstants.TAG_PLAYER);
        if (playerGameObject)
            player = playerGameObject.GetComponent<PlayerControl>();
        else
            Debug.LogError(TextConstants.PLAYER_NOT_FOUND_ERROR);

        return player;
    }

    public static CameraControl FindCamera()
    {
        CameraControl camera = null;

        GameObject cameraGameObject = GameObject.FindGameObjectWithTag(TagConstants.TAG_PLAYER);
        if (cameraGameObject)
            camera = cameraGameObject.GetComponentInChildren<CameraControl>();
        else
            Debug.LogError(TextConstants.CAMERA_NOT_FOUND_ERROR);

        return camera;
    }
	
	 public static MenuControl FindMenu()
    {
        MenuControl menu = null;

        GameObject menuGameObject = GameObject.FindGameObjectWithTag(TagConstants.TAG_MENU);
        if (menuGameObject)
            menu = menuGameObject.GetComponentInChildren<MenuControl>();
        else
            Debug.LogError(TextConstants.MENU_NOT_FOUND_ERROR);

        return menu;
    }
	
	public static bool PauseGame(bool paused){
		if(!paused)
		{
			Time.timeScale = 0;
			paused = true;
		}
		
		return paused;
	}
	
	public static bool UnpauseGame(bool paused){
		if(paused)
		{
			Time.timeScale = 1;
			paused = false;
		}
		
		return paused;
	}
    #endregion
}
